import 'package:flutter/material.dart';

class Demo01Widget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Demo01HomePage();
  }
}


class Demo01ContentWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Image.asset('images/lake.jpg', fit: BoxFit.cover,),
    );
  }

}

class Demo01HomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Demo01HomeState();
  }

}

class Demo01HomeState extends State<Demo01HomePage> {

  var ratings = Container(
    padding: EdgeInsets.all(20.0),
    child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: <Widget>[
        Row(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Icon(Icons.star, color: Colors.black,),
            Icon(Icons.star, color: Colors.black,),
            Icon(Icons.star, color: Colors.black,),
            Icon(Icons.star, color: Colors.black,),
            Icon(Icons.star, color: Colors.black,),
          ],
        ),
        Text(
          '170 Reviews',
          style: TextStyle(
              color: Colors.black,
              fontWeight: FontWeight.w800,
              fontFamily: 'Roboto',
              letterSpacing: 0.5,
              fontSize: 20.0
          ),
        )
      ],
    ),
  );


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(icon: Icon(Icons.arrow_back), onPressed: () {
          Navigator.of(context).pop();
        }),
        title: Text('构建布局', style: TextStyle(fontSize: 20.0),),
      ),
      body: DefaultTextStyle.merge(
          style: TextStyle(
              color: Colors.black,
              fontWeight: FontWeight.w800,
              fontFamily: 'roboto',
              letterSpacing: 0.5,
              fontSize: 18.0,
              height: 2.0
          ),
          child: Material(
            type: MaterialType.card,
            elevation: 5.0,
            shadowColor: Colors.green,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                IconListItem(Icons.kitchen, 'PREP', '25 min'),
                IconListItem(Icons.timer, 'COOK', '45 min'),
                IconListItem(Icons.restaurant, 'FEEDS', '15 min'),
              ],
            ),
          )
      ),

    );
  }

}

class IconListItem extends StatefulWidget {
  IconData icon;
  String title;
  String subtitle;

  IconListItem(this.icon, this.title, this.subtitle);

  @override
  State<StatefulWidget> createState() {
    return IconListItemState(this.icon, this.title, this.subtitle);
  }

}

class IconListItemState extends State<IconListItem> {
  IconData icon;
  String title;
  String subtitle;

  IconListItemState(this.icon, this.title, this.subtitle);

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.start,
      children: <Widget>[
        Icon(this.icon, color: Colors.green,),
        Text(this.title, style: TextStyle(fontSize: 18.0, color: Colors.black)),
        Text(this.subtitle,
            style: TextStyle(fontSize: 15.0, color: Colors.black)),
      ],
    );
  }

}